<?php
 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation; either version 2
 // of the License, or (at your option) any later version.
?>

<head>
    <link rel="stylesheet" href="<?php css_src('rules.css') ?>" type="text/css">
	
    <script language="javascript" src="../../../library/dialog.js"></script>
	<!--script type="text/javascript" src="<?php echo $web_root; ?>/library/js/jquery-1.10.0.min.js"></script-->
	<script type="text/javascript" src="<?php  echo $GLOBALS['webroot']  ?>/library/js/jquery.fancybox.pack.js"></script>
	<!--link rel="stylesheet" href="<?php echo $web_root; ?>/patients/css/jquery.autocomplete.css" type="text/css"/-->
	<!--script type="text/javascript" src="<?php echo $web_root; ?>/patients/js/jquery.autocomplete.js"></script-->
    <script type="JavaScript">
	
		$( document ).ready(function() {
			sel_diagnosis2();
			$("#fld_value").autocomplete("<?php echo $web_root; ?>/patients/medical_problem_autocomplete.php?medico=1",
			{
				minChars: 3,
				matchSubset: 1,
				matchContains: 1,
				selectFirst: false,
				cacheLength: 10,
				autoFill: false,
				onItemSelect: function(li) {
					$("#fld_value").val($("<div>").html(li.selectValue).text());
				}
			});
		});
        // This invokes the find-code popup.
        function sel_diagnosis() {
            //dlgopen('../../patient_file/encounter/find_code_popup.php', '_blank', 500, 400);
			//alert('../../patient_file/encounter/find_code_popup.php');
			var myurl = '<?php echo $GLOBALS['web_root']; ?>/interface/main/drugs/find_patient_popup.php' ;
				parent.$.fancybox({
					href: myurl,
					autoSize: true,
					type: 'iframe',
					helpers: {
						overlay: {
							opacity: 0.3,
							css: {
								'background': 'rgba(255, 254, 254,0.85)'
							}
						} // overlay
					} // helpers
				}); // fancybox
        }
		
		
		$("#fld_value").autocomplete("<?php echo $web_root; ?>/patients/medical_problem_autocomplete.php?medico=1",
			{
				minChars: 3,
				matchSubset: 1,
				matchContains: 1,
				selectFirst: false,
				cacheLength: 10,
				autoFill: false,
				onItemSelect: function(li) {
					$("#fld_value").val($("<div>").html(li.selectValue).text());
				}
			});
		
		
        // This is for callback by the find-code popup.
        // Only allows one entry.
        function set_related(codetype, code, selector, codedesc) {
            /*var f = document.forms[0];
            var s = '';
            if (code) {
                s = codetype + ':' + code;
            }
            f.fld_value.value = s;*/
        }
    </script>
</head>

<!-- diagnosis -->
<p class="row">
    <span class="left_col colhead req" data-fld="fld_diagnosis"><?php echo out( $criteria->getTitle() ); ?></span>
    <!--span class="end_col"><input id="fld_value" type="text" name="fld_value" class="field" onclick="sel_diagnosis()" value="<?php echo out( $criteria->getRequirements() ); ?>"></span-->
    <span class="end_col"><input id="fld_value" type="text" name="fld_value" class="field"  value="<?php echo out( $criteria->getRequirements() ); ?>"></span>
</p>

<br/>

<!-- optional/required and inclusion/exclusion fields -->
<?php echo common_fields( array( "criteria" => $criteria) ); ?>
